package com.lyd.springtestapi.controller;

import com.lyd.springtestapi.dao.t_userRepository;
import com.lyd.springtestapi.domain.ResultVO;
import com.lyd.springtestapi.utils.ResultUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class t_userController {
    @Resource
    private t_userRepository t_userRepository;


    @GetMapping("/getUser")
    public ResultVO getUser() {
        return ResultUtils.success(t_userRepository.findAll());
    }

    @PostMapping("/getUser1")
    public ResultVO getUser1() {
        return ResultUtils.success(t_userRepository.findAll());
    }

    @GetMapping("/getAllUser")
    public ResultVO getAllUser(Integer id, Integer role) {
        return ResultUtils.success(t_userRepository.getAllUser(id, role));
    }
    /*@RequestMapping("/getAllUser")
    public List<t_user> getAllUser(Integer id ,Integer role) {
        return t_userRepository.getAllUser(id,role);
    }*/

    @PostMapping("/setUserName")
    public ResultVO setUserName(String username, Integer id) {
        return ResultUtils.success(t_userRepository.setUserName(username, id));
    }

    @PostMapping("/deleteUser")
    public ResultVO deleteUser(Integer id) {
        return ResultUtils.success(t_userRepository.deleteUser(id));
    }

    @PostMapping("/insertUser")
    public ResultVO insertUser(Integer id, Integer role, String username, String email, String gender, String createtime, Integer flag, String activatecode) {
        return ResultUtils.success(t_userRepository.insertUser(id, role, username, email, gender, createtime, flag, activatecode));
    }
}
